package com.xiao.webtest.dao;

import com.xiao.webtest.DataSource;
import com.xiao.webtest.entity.UserEntity;

import org.springframework.stereotype.Repository;

/**
 * Created by Administrator on 2014/11/15.
 */
@Repository("userDao")
public class UserDaoImpl extends BaseDao implements UserDao {

	public UserEntity getById(long id) {
		String sql = "SELECT id,username,PASSWORD FROM t_user where id = " + id;
		// String sql =
		// "SELECT id,username,PASSWORD FROM reg_user where id = "+id;
		return super.getJavaBean(sql, UserEntity.class);
	}

	public int update(UserEntity user) {
		String sql = "UPDATE t_user t SET t.`username` =?,t.`password` =? where id =?";
		return super.commonUpdate(sql, user.getUsername(), user.getPassword(),
				user.getId());
	}

	public UserEntity getByName(String name) {
		String sql = "SELECT id,username,PASSWORD FROM t_user where username = '"+name+"'";
		return super.getJavaBean(sql, UserEntity.class);
	}

}
